/**
 * Created by Jack on 2015/8/18.
 */
var AV = require('leanengine');

//操作产品的模型信息
var Homepage = AV.Object.extend("Homepage");
var Classify = AV.Object.extend("Classify");
var User = AV.Object.extend("_User");

module.exports = {
    getHomepage:function(){
        var query = new AV.Query(Homepage);
        query.equalTo('status',"1");
        query.equalTo('channel',"1");
        query.descending('cName');
        query.ascending('ordnum');
        return query.find();
    },
    getHomeClassify:function(classifyArr){
        var query = new AV.Query(Classify);
        query.containedIn('gjz',classifyArr);
        //query.equalTo('isshow','1');
        //query.addDescending('isNice')
        query.ascending('orderno');
        return query.find();
    },

    dayMark:function(userid){
        if(userid){
            var query = new AV.Query(User);
            query.equalTo('objectId',userid);
            return query.first();
        } else{
            //throw 'userid should not be empty!';
            return new AV.Promise.error("userid should not be empty!");
        }
    }
};
